//
//  BinSpecTableviewCell.swift
//  Wmsmobile
//
//  Created by Nick xu on 16/8/19.
//  Copyright © 2016年 www.hd123.com. All rights reserved.
//

import UIKit
 // 货品信息、查询货位 共用此cell
class HDBinSpecTableviewCell: HDFounctionBaseCell {

   //MARK: - property
    var dict: Dictionary<String , String>?{
        didSet{
            labelLeft.text = dict!["left"] ?? ""
            labelRight.text = dict!["right"] ?? ""
            labelCenter.text = dict!["middle"] ?? ""
            if dict!["left"] != nil {
                accessorView.isHidden = false
            }else{
                accessorView.isHidden = true
            }
        }
    }
    
    lazy var labelLeft:UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: self.getFont())
        label.textColor = UIColor.hexStringToUIColor("#666666")
//        label.backgroundColor = UIColor.redColor()
        return label
    }()
    lazy fileprivate var labelRight:UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: self.getFont())
        label.textColor = UIColor.hexStringToUIColor("#666666")
//        label.backgroundColor = UIColor.redColor()
        return label
    }()
    lazy var labelCenter:UILabel = {
        let label = UILabel()
        label.text = "无数据"
        label.font = UIFont.systemFont(ofSize: self.getFont())
        label.textColor = UIColor.hexStringToUIColor("#666666")
//        label.backgroundColor = UIColor.redColor()
        label.textAlignment = .center
        return label
    }()
    lazy fileprivate var accessorView:UIImageView = {
        let imView = UIImageView()
        imView.image = UIImage(named: "箭头icon")
        return imView
    }()
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    required init() {
        fatalError("init() has not been implemented")
    }
    
    func setupUI() {
        self.selectionStyle = .default
        accessorView.isHidden = true
        self.contentView.addSubview(labelLeft)//添加sunveiw
        self.contentView.addSubview(labelRight)
        self.contentView.addSubview(accessorView)
        self.contentView.addSubview(labelCenter)
        //布局subview
        labelLeft.snp.makeConstraints { (make) in
            make.left.equalTo(self).offset(18)
            make.centerY.equalTo(self)
            make.width.equalTo(100)
        }
        accessorView.snp.makeConstraints { (make) in
            make.trailing.equalTo(self).offset(-15)
            make.centerY.equalTo(self)
            make.width.equalTo(22)
            make.height.equalTo(22)
        }
        labelRight.snp.makeConstraints { (make) in
            make.trailing.equalTo(accessorView.snp.leading).offset(-10)
            make.centerY.equalTo(self)
        }
        labelCenter.snp.makeConstraints { (make) in
            make.center.equalTo(self)
            make.width.equalTo(80)
        }
    }
}
